/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmManageAlumnos.java
 *
 * Created on 17/03/2013, 14:16:28
 */
package ssga.gui;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import ssga.DAO.ABMAlumnosDAO;
import ssga.dataIO.DataIO;
import ssga.pojos.EntidadAlumno;
import ssga.utils.DataCache;
import ssga.validator.Validator;
import ssga.views.EntidadView;

/**
 *
 * @author David
 */
public class frmManageAlumnos extends javax.swing.JInternalFrame {

    private Validator vl = new Validator();
    private static List<String> listError = new ArrayList<String>();
    public String action = null;
    private String error = null;
    
    /** Creates new form frmAlumnos 
     *  le quita los bordes y lo agrega a la lista de ventanas abiertas     
     */
    public frmManageAlumnos(String accion) {

//        javax.swing.plaf.InternalFrameUI fui = getUI();
//        if (fui instanceof BasicInternalFrameUI) {
//            ((BasicInternalFrameUI) fui).setNorthPane(null);
//        }
        initComponents();
        frmPrincipal.listWin.add(frmManageAlumnos.this);
        List<EntidadView> le = DataCache.getEntidades("spCarrera");
        initCombos(le);        
        if(accion.equalsIgnoreCase("view")){
            viewAlumno(false);
        }else{
            reset();        
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        lblNroDoc = new javax.swing.JLabel();
        lblFechaNac = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        lblLugNac = new javax.swing.JLabel();
        lblNac = new javax.swing.JLabel();
        lblDir = new javax.swing.JLabel();
        lblLocalidad = new javax.swing.JLabel();
        lblTel = new javax.swing.JLabel();
        lblCel = new javax.swing.JLabel();
        lblMail = new javax.swing.JLabel();
        txtApeNom = new javax.swing.JTextField();
        cbTdni = new javax.swing.JComboBox();
        txtNroDoc = new javax.swing.JTextField();
        txtFechaNac = new javax.swing.JTextField();
        txtLugNac = new javax.swing.JTextField();
        txtNacionalidad = new javax.swing.JTextField();
        txtDireccion = new javax.swing.JTextField();
        txtTelefono = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        cbSexo = new javax.swing.JComboBox();
        txtCelular = new javax.swing.JTextField();
        txtLocalidad = new javax.swing.JTextField();
        lblApeNom = new javax.swing.JLabel();
        lblCp = new javax.swing.JLabel();
        txtCp = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        lblEscuela = new javax.swing.JLabel();
        lblTitulo = new javax.swing.JLabel();
        lblOrientacion = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        lblFechaInsc = new javax.swing.JLabel();
        lblFechabaja = new javax.swing.JLabel();
        lblLegajo = new javax.swing.JLabel();
        lblPlan = new javax.swing.JLabel();
        lblPlan2 = new javax.swing.JLabel();
        lblNroInsc = new javax.swing.JLabel();
        txtEscuela = new javax.swing.JTextField();
        txtOrientacion = new javax.swing.JTextField();
        txtTitulo = new javax.swing.JTextField();
        cbDebeTitulo = new javax.swing.JComboBox();
        txtLegajo = new javax.swing.JTextField();
        txtNroInsc = new javax.swing.JTextField();
        txtFechaInsc = new javax.swing.JTextField();
        txtFechaBaja = new javax.swing.JTextField();
        cbPlan1 = new javax.swing.JComboBox();
        cbPlan2 = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        btnGrabar = new javax.swing.JButton();
        btnReset = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnEdit = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosed(evt);
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Personales"));

        jLabel3.setText("Tipo Doc.:");

        lblNroDoc.setText("Nro. Doc.:");

        lblFechaNac.setText("Fecha de Nac.:");

        jLabel10.setText("Sexo:");

        lblLugNac.setText("Lugar de Nac.:");

        lblNac.setText("Nacionalidad:");

        lblDir.setText("Dirección:");

        lblLocalidad.setText("Localidad:");

        lblTel.setText("Teléfono:");

        lblCel.setText("Celular:");

        lblMail.setText("E-mail:");

        txtApeNom.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtApeNomFocusLost(evt);
            }
        });

        cbTdni.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "DNI", "LC", "LER" }));

        txtNroDoc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtNroDocFocusLost(evt);
            }
        });

        txtFechaNac.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtFechaNacFocusLost(evt);
            }
        });

        txtLugNac.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtLugNacFocusLost(evt);
            }
        });

        txtNacionalidad.setText("A");

        txtDireccion.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDireccionFocusLost(evt);
            }
        });

        txtTelefono.setText("0");

        txtEmail.setText("NO");

        cbSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "M", "F" }));

        txtCelular.setText("0");

        lblApeNom.setText("Nombre y Apellido:");

        lblCp.setText("Codigo Postal:");

        txtCp.setText("0");
        txtCp.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtCpFocusLost(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel4.setText("Ej.: 01/02/2013");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblFechaNac)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblApeNom)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(txtFechaNac, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
                                            .addComponent(cbTdni, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txtNacionalidad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(cbSexo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel4)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(lblLugNac)
                                                .addGap(18, 18, 18)
                                                .addComponent(txtLugNac, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(lblNroDoc)
                                                .addGap(18, 18, 18)
                                                .addComponent(txtNroDoc, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                    .addComponent(txtDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
                                    .addComponent(txtLocalidad, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtCp, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(txtTelefono, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(txtCelular, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
                                    .addComponent(txtApeNom, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE))
                                .addGap(22, 22, 22)))
                        .addContainerGap())
                    .addComponent(lblDir)
                    .addComponent(lblLocalidad)
                    .addComponent(lblCp)
                    .addComponent(lblTel)
                    .addComponent(lblCel)
                    .addComponent(lblMail)
                    .addComponent(lblNac)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblApeNom)
                    .addComponent(txtApeNom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(cbTdni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNroDoc)
                    .addComponent(txtNroDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFechaNac)
                    .addComponent(txtFechaNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblLugNac)
                    .addComponent(txtLugNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(cbSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(17, 17, 17)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNac)
                    .addComponent(txtNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDir)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblLocalidad)
                    .addComponent(txtLocalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblCp)
                    .addComponent(txtCp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTel)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCel)
                    .addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblMail)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Académicos"));

        lblEscuela.setText("Escuela:");

        lblTitulo.setText("Título:");

        lblOrientacion.setText("Orientación");

        jLabel17.setText("Debe Título:");

        lblFechaInsc.setText("Fecha Inscripción:");

        lblFechabaja.setText("Fecha Baja:");

        lblLegajo.setText("Legajo:");

        lblPlan.setText("Código Plan 1:");

        lblPlan2.setText("Código Plan 2:");

        lblNroInsc.setText("Nro. Inscripción:");

        txtEscuela.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtEscuelaFocusLost(evt);
            }
        });

        txtOrientacion.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtOrientacionFocusLost(evt);
            }
        });

        txtTitulo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtTituloFocusLost(evt);
            }
        });

        cbDebeTitulo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SI", "NO" }));

        txtLegajo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtLegajoFocusLost(evt);
            }
        });

        txtNroInsc.setText("0");
        txtNroInsc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtNroInscFocusLost(evt);
            }
        });

        txtFechaInsc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtFechaInscFocusLost(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Ej.: 01/02/2013");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setText("Ej.: 01/02/2013");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblOrientacion)
                            .addComponent(lblTitulo)
                            .addComponent(lblEscuela))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtEscuela)
                            .addComponent(txtTitulo)
                            .addComponent(txtOrientacion, javax.swing.GroupLayout.PREFERRED_SIZE, 345, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(lblPlan)
                    .addComponent(lblPlan2)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblFechaInsc)
                            .addComponent(lblFechabaja)
                            .addComponent(lblNroInsc)
                            .addComponent(jLabel17)
                            .addComponent(lblLegajo))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbDebeTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtLegajo, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNroInsc, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(cbPlan2, 0, 344, Short.MAX_VALUE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtFechaBaja)
                                    .addComponent(txtFechaInsc, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2)))
                            .addComponent(cbPlan1, 0, 345, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEscuela, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblEscuela))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblTitulo))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtOrientacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblOrientacion))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(cbDebeTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblLegajo)
                    .addComponent(txtLegajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNroInsc)
                    .addComponent(txtNroInsc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFechaInsc)
                    .addComponent(txtFechaInsc, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFechabaja)
                    .addComponent(txtFechaBaja, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblPlan)
                    .addComponent(cbPlan1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblPlan2)
                    .addComponent(cbPlan2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(47, 47, 47))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnGrabar.setText("Grabar");
        btnGrabar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGrabarActionPerformed(evt);
            }
        });

        btnReset.setText("Limpiar");
        btnReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnResetActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnEdit.setText("Editar");
        btnEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnEdit)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 630, Short.MAX_VALUE)
                .addComponent(btnGrabar)
                .addGap(18, 18, 18)
                .addComponent(btnCancelar)
                .addGap(19, 19, 19)
                .addComponent(btnReset)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(27, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnReset)
                    .addComponent(btnCancelar)
                    .addComponent(btnGrabar)
                    .addComponent(btnEdit))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnResetActionPerformed
// Reseteo de la pantalla    
    System.out.println("Limpieza de Pantalla");
    reset();
}//GEN-LAST:event_btnResetActionPerformed

private void btnGrabarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGrabarActionPerformed
    //Ultima Validacion de los combos
    this.validaCarreras();

    // Comienza el proceso de grabado de datos
    System.out.println("Inicio de Alta de alumno");

    if (listError.isEmpty()) {
        initAction(this.action);
    } else {
        String str = actionError(listError);
        JOptionPane.showMessageDialog(null, str, "AVISO -  ERRORES",
                JOptionPane.ERROR_MESSAGE);
    }
}//GEN-LAST:event_btnGrabarActionPerformed

private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
// Proceso de cancelae Alta/Editar alumno
    int opc = JOptionPane.showConfirmDialog(null, "¿Desea Cancelar?");

    if (JOptionPane.OK_OPTION == opc) {
        System.out.println("Cerrar");
        this.dispose();
        frmPrincipal.listWin.remove(this);
    } else {
        System.out.println("no borro nada...");
    }
}//GEN-LAST:event_btnCancelarActionPerformed

// Metodo que se encarga de validar que los datos que se ingresan no sean nulos
    /**
     * validacion de que el nro de documento sea un numero 
     * @param evt 
     */
private void txtNroDocFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNroDocFocusLost
    error = "Nro de Documento debe ser un numero";
    this.txtNroDoc.getText().replace(".", "");
    if (vl.validate(this.lblNroDoc, this.txtNroDoc, 1)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtNroDocFocusLost

    /**
     *  Validacion de que el lugar de nacimiento no sea vacio
     * @param evt 
     */
private void txtLugNacFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtLugNacFocusLost
    error = "Lugar de Nacimiento No puede estar vacio";
    if (vl.validate(this.lblLugNac, this.txtLugNac, 2)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtLugNacFocusLost

    /**
     * Si no ingresa ningun valor pone un 0
     * @param evt 
     */
private void txtNroInscFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNroInscFocusLost
    error = "Nro de Inscripcion no puede estar vacio";
    if (vl.validate(this.lblNroInsc, this.txtNroInsc, 1)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtNroInscFocusLost

    /**
     * Codigo Postal no NULO
     * @param evt 
     */
private void txtCpFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtCpFocusLost
    error = "Codigo Postal debe ser un Numero";
    if (vl.validate(this.lblCp, this.txtCp, 1)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtCpFocusLost

    /**
     * La direccion no puede estar vacia
     * @param evt 
     */
private void txtDireccionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDireccionFocusLost
    error = "Dirección No puede estar vacio";

    if (vl.validate(this.lblDir, this.txtDireccion, 2)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtDireccionFocusLost

    /**
     * Nombre y Apellido NO NULO
     * @param evt 
     */
private void txtApeNomFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtApeNomFocusLost
    error = "Apellido y Nombre No puede estar vacio";
    if (vl.validate(this.lblApeNom, this.txtApeNom, 2)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtApeNomFocusLost

    /**
     * Valida que el legajo del alumno no sea nulo y mayor a 0
     * @param evt 
     */
private void txtLegajoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtLegajoFocusLost
    error = "Legajo No puede estar vacio";
    if (vl.validate(this.lblLegajo, this.txtLegajo, 1)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtLegajoFocusLost

    /*
     * valida que los datos de la escuela no sean nulos
     * @param evt 
     */
private void txtEscuelaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtEscuelaFocusLost
    error = "Escuela No puede estar vacio";
    if (vl.validate(this.lblEscuela, this.txtEscuela, 2)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtEscuelaFocusLost

    /**
     * Valida que el titulo no sea Vacio
     * @param evt 
     */
private void txtTituloFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtTituloFocusLost
    error = "Título No puede estar vacio";
    if (vl.validate(this.lblTitulo, this.txtTitulo, 2)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtTituloFocusLost

    /**
     * Valida que la Orientacion no sea Vacio
     * @param evt 
     */
private void txtOrientacionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtOrientacionFocusLost
    error = "Orientación No puede estar vacio";
    if (vl.validate(this.lblOrientacion, this.txtOrientacion, 2)) {
        delError(error);
    } else {
        addError(error);
    }
}//GEN-LAST:event_txtOrientacionFocusLost

    /**
     * Verifica que la fecha ingresada este en el formato Correcto
     * @param evt 
     */
private void txtFechaInscFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtFechaInscFocusLost
    error = "Fecha Inscripcion No Tiene el Formato Correcto";

    if (vl.validate(this.lblFechaInsc, this.txtFechaInsc, 3)) {
        delError(error);
    } else {
        addError(error);
    }
    System.out.println("FECHA INSCRIPCION: " + this.txtFechaInsc.getText());
}//GEN-LAST:event_txtFechaInscFocusLost

    /**
     * Valida que la fecha de nacimiento este en formato Correcto
     * @param evt 
     */
private void txtFechaNacFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtFechaNacFocusLost
    error = "Fecha Nacimineto No Tiene el Formato Correcto";

    if (vl.validate(this.lblFechaNac, this.txtFechaNac, 3)) {
        delError(error);
    } else {
        addError(error);
    }
    System.out.println("FECHA nacimieneto " + this.txtFechaInsc.getText());
}//GEN-LAST:event_txtFechaNacFocusLost

    /**
     * Valida que los dos combos contengan numeros de carreras diferentes
     * @param evt 
     */
    private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosed
        //Cuando se cierra la ventana
        frmPrincipal.listWin.remove(this);
    }//GEN-LAST:event_formInternalFrameClosed

    private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
        
        //Boton que habilita la edicion de datos
        viewAlumno(true);
    }//GEN-LAST:event_btnEditActionPerformed

    /** Procedimientos Propios  */
    /**
     * En caso de que haya errores genera la lista para mostrar en el OptionPane
     * @param lista
     * @return String
     */
    private String actionError(List<String> lista) {
        String cadena = "";
        for (String er : lista) {
            cadena += er.toString() + "\n";
        }
        return cadena;
    }

    /**
     * metodo que valida antes de grabar que las carreras seleccionadas no sean
     * iguales
     */
    private void validaCarreras() {
        error = "Los codigo de Planes seleccionados deben ser Diferentes";

        int cod1 = this.cbPlan1.getSelectedItem().hashCode();
        int cod2 = this.cbPlan2.getSelectedItem().hashCode();

        if (vl.isEquals(cod1, cod2, this.lblPlan)) {
            delError(error);
        } else {
            addError(error);
        }
    }

    /**
     * Procedimiento que se encarga de cargar los objetos en el comboBox
     * con las carreras del intituto
     * @param le
     */
    private void initCombos(List<EntidadView> le) {
        for (EntidadView ev : le) {
            System.out.println("VALOR" + ev);
            this.cbPlan1.addItem(ev);
            this.cbPlan2.addItem(ev);
        }
    }

    /**
     * Metodo que se encarga de grabar los datos en la DB
     * de acuerdo a si es un Insert o un Update
     * @param st 
     */
    private void initAction(String st) {

        boolean status = false;
        EntidadAlumno ea = generaAlumno();
        ABMAlumnosDAO abm = new ABMAlumnosDAO();

        try {
            if (st.equals("Insert")) {
                System.out.println("Inicio de Insercion del objeto");
                status = abm.doInsert(ea);
            } else {
                System.out.println("Inicio de Modificación del objeto");
                status = abm.doUpdate(ea);
            }

            System.out.println("Commit");
            status = (status && DataIO.doCommit());

            if (status) {
                JOptionPane.showMessageDialog(null,
                        "Alumno Inscripto Correctamente", "AVISO",
                        JOptionPane.INFORMATION_MESSAGE);
                reset();
            } else {
                JOptionPane.showMessageDialog(null, "Error en " + st + " Alumnos",
                        "AVISO", JOptionPane.ERROR_MESSAGE);
            }

        } catch (Exception e) {
            System.out.println("ERROR en Procedimiento: " + e);
        }
    }

    /**
     * Genera el objeto para insertar en la DB
     * @return  EntidadAlumno
     */
    private EntidadAlumno generaAlumno() {
        EntidadAlumno ea = new EntidadAlumno();

        ea.setApenom(this.txtApeNom.getText());
        ea.setCel(this.txtCelular.getText());
        ea.setCp(Integer.parseInt(this.txtCp.getText())); //---> NUM

        if (this.cbDebeTitulo.getSelectedItem().toString().equals("SI")) {
            ea.setDebeTitulo("S");
        } else {
            ea.setDebeTitulo("N");
        }
        ea.setDir(this.txtDireccion.getText());
        ea.setEmail(this.txtEmail.getText());
        ea.setEscuela(this.txtEscuela.getText());
        ea.setFechaBaja(this.txtFechaBaja.getText());
        ea.setFechaInscr(this.txtFechaInsc.getText());
        ea.setFechaNac(this.txtFechaNac.getText());

        //Combos
        ea.setIdPlan(this.cbPlan1.getSelectedItem().hashCode());
        ea.setIdPlano(this.cbPlan2.getSelectedItem().hashCode());
        //---------------
        ea.setLegajoa(new Integer(this.txtLegajo.getText()));//---> NUM

        ea.setLocalidad(this.txtLocalidad.getText());
        ea.setLugarNac(this.txtLugNac.getText());
        ea.setNacionalidad(this.txtNacionalidad.getText());

        ea.setNdoc(new Integer(this.txtNroDoc.getText()));//---> NUM

        ea.setNroInscr(new Integer(this.txtNroInsc.getText()));//---> NUM

        ea.setOrientacion(this.txtOrientacion.getText());
        ea.setSexo(this.cbSexo.getSelectedItem().toString());
        ea.setTdoc(this.cbTdni.getSelectedItem().toString());
        ea.setTel(this.txtTelefono.getText());
        ea.setTitulo(this.txtTitulo.getText());

        return ea;
    }

    /**
     * Metodo que pone el default todos los valores de la pantalla
     */
    private void reset() {
        //Campos de texto
        this.txtApeNom.setText(null);
        this.lblApeNom.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtCelular.setText("0");
        this.txtDireccion.setText(null);
        this.lblDir.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtCp.setText("0");
        this.lblCp.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtEmail.setText("NO");
        this.txtEscuela.setText(null);
        this.lblEscuela.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtFechaBaja.setText(null);
        this.lblFechabaja.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtFechaInsc.setText(null);
        this.lblFechaInsc.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtFechaNac.setText(null);
        this.lblFechaNac.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtLegajo.setText(null);
        this.lblLegajo.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtLocalidad.setText(null);
        this.lblLocalidad.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtLugNac.setText(null);
        this.lblLugNac.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtNacionalidad.setText("A");
        this.txtNroDoc.setText(null);
        this.lblNroDoc.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtNroInsc.setText("0");
        this.lblNroInsc.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtOrientacion.setText(null);
        this.lblOrientacion.setForeground(Color.getHSBColor(0, 0, 0));
        this.txtTelefono.setText("0");
        this.txtTitulo.setText(null);
        this.lblTitulo.setForeground(Color.getHSBColor(0, 0, 0));
        this.lblPlan.setForeground(Color.getHSBColor(0, 0, 0));
        this.lblPlan2.setForeground(Color.getHSBColor(0, 0, 0));


        //Combos
        this.cbDebeTitulo.setSelectedIndex(0);
        this.cbSexo.setSelectedIndex(0);
        this.cbTdni.setSelectedIndex(0);
        if (this.cbPlan1.getItemCount() != 0) {
            this.cbPlan1.setSelectedIndex(0);
        }
        if (this.cbPlan2.getItemCount() != 0) {
            this.cbPlan2.setSelectedIndex(0);
        }
    }

    /**
     * Proceso que bloquea los controles para que no se pueda editar
     */
    private void viewAlumno(boolean b) {
        //Campos de texto
        this.txtApeNom.setEnabled(b);
        this.txtCelular.setEnabled(b);
        this.txtDireccion.setEnabled(b);
        this.txtCp.setEnabled(b);
        this.txtEmail.setEnabled(b);
        this.txtEscuela.setEnabled(b);
        this.txtFechaBaja.setEnabled(b);
        this.txtFechaInsc.setEnabled(b);
        this.txtFechaNac.setEnabled(b);
        this.txtLegajo.setEnabled(false);
        this.txtLocalidad.setEnabled(b);
        this.txtLugNac.setEnabled(b);
        this.txtNacionalidad.setEnabled(b);
        this.txtNroDoc.setEnabled(b);
        this.txtNroInsc.setEnabled(b);
        this.txtOrientacion.setEnabled(b);
        this.txtTelefono.setEnabled(b);
        this.txtTitulo.setEnabled(b);
        //Combos
        this.cbDebeTitulo.setEnabled(b);
        this.cbSexo.setEnabled(b);
        this.cbTdni.setEnabled(b);
        if (this.cbPlan1.getItemCount() != 0) {
            this.cbPlan1.setEnabled(b);
        }
        if (this.cbPlan2.getItemCount() != 0) {
            this.cbPlan2.setEnabled(b);
        }
        
        //Bloqueo de los botones
        this.btnReset.setEnabled(b);
        this.btnGrabar.setEnabled(b);
    }

    /**
     * Agrega el mensaje de error si no esta
     * @param msg 
     */
    private void addError(String msg) {
        if (!listError.contains(msg)) {
            listError.add(msg);
        }
    }

    /**
     * metodo que remueve el mensage de error de la lista si existe
     * @param msg 
     */
    private void delError(String msg) {
        if (listError.contains(msg)) {
            listError.remove(msg);
        }
    }

    /**
     * Metodo que se encarga de pasar los datos de un alumno seleccionado
     * a la pantalla de aditar
     */
    public void procesaEdicion(EntidadAlumno ea) {

        //Campos de texto
        this.txtApeNom.setText(ea.getApenom());
        this.txtCelular.setText(ea.getCel());
        this.txtDireccion.setText(ea.getDir());
        this.txtCp.setText(Integer.toString(ea.getCp()));
        this.txtEmail.setText(ea.getEmail());
        this.txtEscuela.setText(ea.getEscuela());
        this.txtFechaBaja.setText(ea.getFechaBaja());
        this.txtFechaInsc.setText(ea.getFechaInscr());
        this.txtFechaNac.setText(ea.getFechaNac());
        this.txtLegajo.setText(Integer.toString(ea.getLegajo()));
        this.txtLocalidad.setText(ea.getLocalidad());
        this.txtLugNac.setText(ea.getLugarNac());
        this.txtNacionalidad.setText(ea.getNacionalidad());
        this.txtNroDoc.setText(Integer.toString(ea.getNdoc()));
        this.txtNroInsc.setText(Integer.toString(ea.getNroInscr()));
        this.txtOrientacion.setText(ea.getOrientacion());
        this.txtTelefono.setText(ea.getTel());
        this.txtTitulo.setText(ea.getTitulo());

        //Combos

        if (ea.getDebeTitulo().equalsIgnoreCase("S")) {
            this.cbDebeTitulo.setSelectedItem("SI");
        } else {
            this.cbDebeTitulo.setSelectedItem("NO");
        }

        this.cbSexo.setSelectedItem(ea.getSexo());
        this.cbTdni.setSelectedItem(ea.getTdoc());

        // Variable para rellenar el combo
        int cod;

        if (this.cbPlan1.getItemCount() != 0) {
            switch (ea.getIdPlan()) {
                case 7:
                    cod = 0;
                    break;
                case 8:
                    cod = 1;
                    break;
                case 9:
                    cod = 2;
                    break;
                case 11:
                    cod = 3;
                    break;
                default:
                    cod = 0;
            }
            this.cbPlan1.setSelectedIndex(cod);
        }
        if (this.cbPlan2.getItemCount() != 0) {
            switch (ea.getIdPlano()) {
                case 7:
                    cod = 0;
                    break;
                case 8:
                    cod = 1;
                    break;
                case 9:
                    cod = 2;
                    break;
                case 11:
                    cod = 3;
                    break;
                default:
                    cod = 1;
            }
            this.cbPlan2.setSelectedIndex(cod);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEdit;
    private javax.swing.JButton btnGrabar;
    private javax.swing.JButton btnReset;
    private javax.swing.JComboBox cbDebeTitulo;
    private javax.swing.JComboBox cbPlan1;
    private javax.swing.JComboBox cbPlan2;
    private javax.swing.JComboBox cbSexo;
    private javax.swing.JComboBox cbTdni;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JLabel lblApeNom;
    private javax.swing.JLabel lblCel;
    private javax.swing.JLabel lblCp;
    private javax.swing.JLabel lblDir;
    private javax.swing.JLabel lblEscuela;
    private javax.swing.JLabel lblFechaInsc;
    private javax.swing.JLabel lblFechaNac;
    private javax.swing.JLabel lblFechabaja;
    private javax.swing.JLabel lblLegajo;
    private javax.swing.JLabel lblLocalidad;
    private javax.swing.JLabel lblLugNac;
    private javax.swing.JLabel lblMail;
    private javax.swing.JLabel lblNac;
    private javax.swing.JLabel lblNroDoc;
    private javax.swing.JLabel lblNroInsc;
    private javax.swing.JLabel lblOrientacion;
    private javax.swing.JLabel lblPlan;
    private javax.swing.JLabel lblPlan2;
    private javax.swing.JLabel lblTel;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JTextField txtApeNom;
    private javax.swing.JTextField txtCelular;
    private javax.swing.JTextField txtCp;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtEscuela;
    private javax.swing.JTextField txtFechaBaja;
    private javax.swing.JTextField txtFechaInsc;
    private javax.swing.JTextField txtFechaNac;
    private javax.swing.JTextField txtLegajo;
    private javax.swing.JTextField txtLocalidad;
    private javax.swing.JTextField txtLugNac;
    private javax.swing.JTextField txtNacionalidad;
    private javax.swing.JTextField txtNroDoc;
    private javax.swing.JTextField txtNroInsc;
    private javax.swing.JTextField txtOrientacion;
    private javax.swing.JTextField txtTelefono;
    private javax.swing.JTextField txtTitulo;
    // End of variables declaration//GEN-END:variables
}
